package dse.modules.eln;

import java.util.Collection;
import java.io.Serializable;

import dse.Cluster;
import dse.Node;

public class EarthLikeNetworkCluster extends Cluster implements Serializable
{
	private static final long serialVersionUID = 1L;
	private double x;
	private double y;
	
	public EarthLikeNetworkCluster (
			int id, 
			double x, 
			double y
			)
	{
		super(id);
		this.x = x;
		this.y = y;
	}
	
	public EarthLikeNetworkCluster (
			int id, 
			Collection<? extends Node> nodes,
			double x, 
			double y
			)
	{
		super(id, nodes);
		this.x = x;
		this.y = y;
	}
	
	public double X()
	{
		return x;
	}
	public double Y()
	{
		return y;
	}
	/**
	 * This method should be overriden if possible to provide a better distance
	 * calculation between clusters.  This method need not be exact but since 
	 * it is just used to order clusters by their distance to another cluster.
	 * 
	 * @param other
	 * @return
	 */
	public double distanceTo (Cluster other) {
		if (other instanceof EarthLikeNetworkCluster) {
			EarthLikeNetworkCluster elc = (EarthLikeNetworkCluster)other;
			return GeometryUtil.distance(x, y, elc.x, elc.y);
		}
		return super.distanceTo(other);
	}
}
